package com.juku2024.juku.network.api

import com.juku2024.juku.model.*
import com.juku2024.juku.request.CheckAppRequest
import com.juku2024.juku.request.CommonRequest
import io.reactivex.Observable
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.*


interface Api {

    // checkApp
    @POST("/ctaid/user/login.do")
    suspend fun checkApp(@Body request: CheckAppRequest): CommonResponse?
    // 获取version
    @POST("/ctaid/user/doApiVersion.do")
    suspend fun getVersion(@Body request: CommonRequest): CommonResponse?
    // 获取广告
    @POST("/ctaid/user/getNewAd/{version}.do")
    suspend fun getAds(@Path("version") version: String, @Body request: CommonRequest): CommonResponse?
    // limit
    @POST("/ctaid/user/limit.do")
    suspend fun getLimit(@Body request: CommonRequest): CommonResponse?
    // 导航
    @POST("/ctaid/user/genres.do")
    suspend fun getHome(@Body request: CommonRequest): CommonResponse?
    // 首页
    @POST("/ctaid/user/index/{page}.do")
    suspend fun getRecommend(@Path("page") page: Int, @Body request: CommonRequest, @Query("id") id: Long): CommonResponse?
    // 查看全部
    @POST("/ctaid/user/viewAll/{id}.do")
    suspend fun getAlbumList(@Path("id") id: Long, @Body request: CommonRequest): CommonResponse?
    // 分类 标签
    @POST("/ctaid/user/category/{genreId}.do")
    suspend fun getSearchTag(@Path("genreId") id: Int, @Body request: CommonRequest): CommonResponse?
    // 分类 内容
    @POST("/ctaid/user/albums_page/{genreId}.do")
    suspend fun getCategoryList(@Path("genreId") id: Int, @Body request: CommonRequest): CommonResponse?
    // 热搜
    @POST("/ctaid/user/hots/{id}.do")
    suspend fun getHotSearch(@Path("id") id: String, @Body request: CommonRequest): CommonResponse?
    // 搜索
    @POST("/ctaid/user/search_page.do")
    suspend fun getSearch(@Body request: CommonRequest): CommonResponse?
    // 视频相关推荐
    @POST("/ctaid/user/related/{id}.do")
    suspend fun getVideoRecommend(@Path("id") id: Int, @Body request: CommonRequest): CommonResponse?
    // 获取全部视频详情
    @POST("/ctaid/user/detail/{id}.do")
    suspend fun getVideoDetail(@Path("id") id: Long, @Body request: CommonRequest): CommonResponse?
    // 根据版本号获取部分详情内容
    @POST("/ctaid/user/doUpdateVodVersion.do")
    suspend fun doUpdateVodVersion(@Body request: CommonRequest): CommonResponse?
   // 升级
    @POST("/ctaid/user/upgrade/{id}.do")
    suspend fun upgrade(@Path("id") id: String, @Body request: CommonRequest): CommonResponse?
    // 升级
    @POST("/ctaid/user/doUnlockNav.do")
    suspend fun getUnlock(@Body request: CommonRequest): CommonResponse?
    // checkApp
    @POST("/ctaid/user/login.do")
    fun checkAppObservable(@Body request: CheckAppRequest): Observable<CommonResponse>
    // 升级
    @POST("/ctaid/user/upgrade/{id}.do")
    fun upgradeObservable(@Path("id") id: String, @Body request: CommonRequest): Observable<CommonResponse>
    // 导航
    @POST("/genuine/user/genres.do")
    suspend fun getGenuineGenres(@Body request: CommonRequest): CommonResponse?
    // 导航
    @POST("/genuine/user/index/{page}.do")
    suspend fun getGenuineRecommend(@Path("page") page: Int, @Body request: CommonRequest, @Query("id") id: Long): CommonResponse?
    // 搜索
    @POST("/genuine/user/search_page.do")
    suspend fun getGenuineSearch(@Body request: CommonRequest): CommonResponse?
    // 获取全部视频详情
    @POST("/genuine/user/detail/{id}.do")
    suspend fun getGenuineVideoDetail(@Path("id") id: Long, @Body request: CommonRequest): CommonResponse?
    @POST("/genuine/user/doUnlockNav.do")
    suspend fun getGenuineUnlock(@Body request: CommonRequest): CommonResponse?
    // 分类 内容
    @POST("/genuine/user/albums_page/{genreId}.do")
    suspend fun getGenuineCategoryList(@Path("genreId") id: Int, @Body request: CommonRequest): CommonResponse?
    @GET("/feedbackInfo")
    suspend fun fetchFeedbackInfo(
        @Query("device_id") device_id: String,
        @Query("platform") platform: String,
        @Query("random") random: Long,
        @Query("channel") channel: String
    ): FeedbackInfoModel?
    @GET("/feedbacks/")
    suspend fun postFeedback(
        @QueryMap params: Map<String, String>
    ): FeedbackInfoModel?

    @POST("/ctaid/user/trans/check.do")
    suspend fun verifyApp(@Body request: CommonRequest): CommonResponse?
    // 查看是否有新消息
    @GET
    suspend fun hasNewMsg(@Url url: String, @Query("device_id") device_id: String, @Query("channel") channel: String): FetchSystemNewMsg?

    // 导航内容更新
    @POST("/ctaid/user/genreUpdate/{id}.do")
    suspend fun getHomeItemUpdate(@Path("id") id: Long, @Body request: CommonRequest): CommonResponse?

    @Streaming //注解这个请求将获取数据流,此后将不会这些获取的请求数据保存到内存中,将交与你操作.
    @GET
    fun downloadApk(@Url url: String): Call<ResponseBody>

    // 通知
    @POST("/ctaid/user/appNotice/{appId}.do")
    suspend fun getNotice(@Path("appId") appId: String, @Body request: CommonRequest): CommonResponse?

    // 升级v2
    @POST("/ctaid/user/upgrade/v2/{appId}.do")
    suspend fun getUpdateV2(@Path("appId") appId: String, @Body request: CommonRequest): CommonResponse?

    // 升级v2
    @POST("/ctaid/user/upgrade/v2/{appId}.do")
    fun getUpdateV2Observable(@Path("appId") appId: String, @Body request: CommonRequest): Observable<CommonResponse>

    // 排行榜导航
    @POST("/ctaid/user/ranking/nav.do")
    suspend fun getRankingNavList(@Body request: CommonRequest): CommonResponse?

    // 排行榜导航内容
    @POST("/ctaid/user/ranking/list/{id}.do")
    suspend fun getRankingNavDetailList(@Path("id") id: Int, @Body request: CommonRequest): CommonResponse?
}